package com.syscom.server.qd.vo;

import com.syscom.safe.cache.SafeCacheManager;
import com.syscom.safe.wac.buf.*;
import java.io.IOException;
import com.syscom.shared.server.BinaryTransferVo;

public class RuleQtaStatusVo implements BinaryTransferVo {
	private int RuleId = 0;
	private String ProdId = null;
	private double DispatchQta = 0;
	private double UsedQta = 0;
	private boolean DrawBack = false;
	private String ServerId = null;
	private int TriggerType = 0;

	public int getRuleId() {
		return RuleId;
	}

	public void setRuleId(int value) {
		RuleId = value;
	}

	public String getProdId() {
		return ProdId;
	}

	public void setProdId(String value) {
		ProdId = value;
	}

	public double getDispatchQta() {
		return DispatchQta;
	}

	public void setDispatchQta(double value) {
		DispatchQta = value;
	}

	public double getUsedQta() {
		return UsedQta;
	}

	public void setUsedQta(double value) {
		UsedQta = value;
	}

	public boolean getDrawBack() {
		return DrawBack;
	}

	public void setDrawBack(boolean value) {
		DrawBack = value;
	}

	public String getServerId() {
		return ServerId;
	}

	public void setServerId(String value) {
		ServerId = value;
	}
	
	public int getTriggerType() {
		return TriggerType;
	}
	
	public void setTriggerType(int value) {
		TriggerType = value;
	}

	public RuleQtaStatusVo() {};

	public RuleQtaStatusVo(int RuleId, String ProdId, int TrigStatus, double InitQta, double UsedQta, boolean DrawBack, int TriggerType) {
		this.RuleId = RuleId;
		this.ProdId = ProdId;
		this.DispatchQta = InitQta;
		this.UsedQta = UsedQta;
		this.DrawBack = DrawBack;
		this.TriggerType = TriggerType;
	}

	public static String getKeyString(int RuleId, String ProdId) {
		StringBuilder sb = new StringBuilder();
		sb.append(RuleId);
		sb.append(SafeCacheManager.CACHE_KEY_DELIMITER);
		sb.append(ProdId);

		return sb.toString();
	}

	@Override
	public void parseInBuffer(SacInputBuffer sacInput) throws IOException {
		RuleId = sacInput.readInt();
		ProdId = sacInput.readShortString();
		DispatchQta = sacInput.readDouble();
		UsedQta = sacInput.readDouble();
		DrawBack = sacInput.readBoolean();
		ServerId = sacInput.readAutoString();
		TriggerType = sacInput.readInt();
	}

	@Override
	public void fillOutBuffer(SacOutputBuffer sacOutput) throws IOException {
		sacOutput.writeInt(RuleId);
		sacOutput.writeShortString(ProdId);
		sacOutput.writeDouble(DispatchQta);
		sacOutput.writeDouble(UsedQta);
		sacOutput.writeBoolean(DrawBack);
		sacOutput.writeAutoString(ServerId);
		sacOutput.writeInt(TriggerType);
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("RuleId=");
		sb.append(RuleId);
		sb.append(';');
		sb.append("ProdId=");
		sb.append(ProdId);
		sb.append(';');
		sb.append("InitQta=");
		sb.append(DispatchQta);
		sb.append(';');
		sb.append("UsedQta=");
		sb.append(UsedQta);
		sb.append(';');
		sb.append("DrawBack=");
		sb.append(DrawBack);
		sb.append(';');
		sb.append("ServerId=");
		sb.append(ServerId);
		sb.append("TriggerType=");
		sb.append(TriggerType);

		return sb.toString();
	}
}